package com.example.shardingmultdatasource.service;

import com.example.shardingmultdatasource.config.DataSource;
import com.example.shardingmultdatasource.dao.OrderMapper;
import com.example.shardingmultdatasource.entity.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Service(value = "orderService")
@Transactional
@DataSource
public class OrderService {

    @Autowired
    private OrderMapper orderMapper;

//    @DataSource(param = "orderId")
    public Order selectByPrimaryKey(String orderId) {
        return orderMapper.selectByPrimaryKey(orderId);

    }

    @DataSource
    public Integer insert(String orderId,Order order) {
        return orderMapper.insert(order);
    }

    public Integer insertList(List<Order> orderId){
        return orderMapper.insertList(orderId);
    }
}